package server.core;

/**
 * describe: 售出状态
 *
 * @author helloworldyu
 * @data 2018/3/23
 */
public class SoldingState extends AbstractState{
	public SoldingState(GumballMachine machine) {
		super(machine);
	}

	@Override
	public void insertQuarter() {
		System.out.println("正在出售糖果请稍后再试!!!!!!!!");
	}

	@Override
	public void ejectQuarter() {
		System.out.println("你已经转动了手柄不能回退硬币了");
	}

	@Override
	public void turnCrank() {
		System.out.println("你已经转动了手柄，不能再转动手柄了");
	}

	@Override
	public void dispense() {
		gumballMachine.releaseBall();
		if( gumballMachine.getCount() >0 ){
			gumballMachine.setState( gumballMachine.getNoQuarterState() );
		}else {
			gumballMachine.setState( gumballMachine.getSoldOutState() );
		}
	}
}